const Mock = require('mockjs')

const NameList = []
const count = 100

for (let i = 0; i < count; i++) {
  NameList.push(Mock.mock({
    name: '@first'
  }))
}
NameList.push({ name: 'mock-Pan' })

module.exports = [
  {
    url: '/vue-element-admin/dataQuery/setView/',
    type: 'post',
    response: config => {
      return {
        code: 200,
        message: 'success'
      }
    }
  },
  {
    url: '/vue-element-admin/dataQuery/getThreshold/',
    type: 'get',
    response: config => {
      return {
        code: 200,
        message: 'success',
        threshold: 0.4
      }
    }
  },
  {
    url: '/vue-element-admin/dataQuery/setThreshold/',
    type: 'post',
    response: config => {
      return {
        code: 200,
        message: 'success'
      }
    }
  },
  {
    url: '/vue-element-admin/dataQuery/getList/',
    type: 'get',
    response: config => {
      const queryList = [
        {
          'item_id': 1,
          'place': 'xxx',
          'name': 'test',
          'time': '2024-4-15',
          'detected_img_path': '2131H.jpg',
          'original_img_path': '2131H.jpg'
        },
        {
          'item_id': 2,
          'place': 'yyy',
          'name': 'val',
          'time': '2024-4-15',
          'detected_img_path': '2131H.jpg',
          'original_img_path': '2131H.jpg'
        }
      ]
      return {
        code: 200,
        message: 'success',
        data: queryList,
        total: 10
      }
    }
  },
  // username search
  {
    url: '/vue-element-admin/search/user',
    type: 'get',
    response: config => {
      const { name } = config.query
      const mockNameList = NameList.filter(item => {
        const lowerCaseName = item.name.toLowerCase()
        return !(name && lowerCaseName.indexOf(name.toLowerCase()) < 0)
      })
      return {
        code: 200,
        data: { items: mockNameList }
      }
    }
  },

  // transaction list
  {
    url: '/vue-element-admin/transaction/list',
    type: 'get',
    response: _ => {
      return {
        code: 200,
        data: {
          total: 20,
          'items|20': [{
            order_no: '@guid()',
            timestamp: +Mock.Random.date('T'),
            username: '@name()',
            price: '@float(1000, 15000, 0, 2)',
            'status|1': ['success', 'pending']
          }]
        }
      }
    }
  },
  {
    url: '/vue-element-admin/systemconfiguration/startInspec',
    type: 'get',
    response: config => {
      return {
        code: 200,
        data: 1
      }
    }
  },
  {
    url: '/vue-element-admin/systemconfiguration/stopInspec',
    type: 'get',
    response: config => {
      return {
        code: 200,
        data: 1
      }
    }
  },
  {
    url: '/vue-element-admin/SystemConfiguration/getConfig',
    type: 'get',
    response: config => {
      return {
        message: 'right',
        status: 200,
        data: {
          input_type: 0,
          input_view: 1,
          source: 'x',
          status: 0,
          threshold: 0.5
        }
      }
    }
  },
  {
    url: '/vue-element-admin/SystemConfiguration/updateThreshold',
    type: 'post',
    response: config => {
      return {
        message: 'right',
        status: 200,
        data:{
          threshold: 0.5
        }
      }
    }
  },
  {
    url: '/vue-element-admin/SystemConfiguration/updateDetectStatus',
    type: 'post',
    response: config => {
      return {
        message: 'right',
        status: 200,
        data:{
          status:1
        }
      }
    }
  }
]
